// When page has finished loading
function generate_toc_() {  
	// Check if the element exists
	if($('toc')){
		var show = false;
		var toc_i = 0;
		// Check the div contaning headings you want to have in your table of contents	
		$$('h3').each(function(element){
			toc_i++;
			show 			= true;
			// Add an id to the headings for linking
			toc_title_id		= 'article_chapter_' + toc_i;
			$(element).id 		= toc_title_id;
			if(element.tagName == 'H2' || element.tagName == 'h2'){					
				$('toc').innerHTML 	+= '    - <a href="#' + $(element).id + '" onclick="$(element).scrollTo($(element));">' + element.innerHTML.stripTags() + '</a><br /' + '>';				
			}
			else{
           $('toc').innerHTML 	+= '<span style="border-width:5px;">' + toc_i + '. <a href="#' + $(element).id + '" onclick="$(element).scrollTo($(element));">' + element.innerHTML.stripTags() + '</a></span><br /' + '>';
			}
			// Scroll to top
			//$(element).innerHTML	+= '<a href="#post_content" onclick="$(\'post_content\').scrollTo($(\'post_content\'));" class="backToTop">#top</a>';
		}); 
		if(show){
			$('toc').appear();
		}
	}
}